Operator overloading allows the basic C/C++ operators to have user-defined meanings on user-defined types (classes). They are syntactic sugar for equivalent function calls; ex:
class X {
//...
public:
//...
};
X add(X, X); //a top-level function that adds two X's
X mul(X, X); //a top-level function that multiplies two X's
X f(X a, X b, X c)
{
return add(add(mul(a,b), mul(b,c)), mul(c,a));
}
Now merely replace 'add' with 'operator+' and 'mul' with 'operator*':
X operator+(X, X); //a top-level function that adds two X's
X operator*(X, X); //a top-level function that multiplies two X's